package books.borrowing.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "SUBSCRIBERS", uniqueConstraints = { @UniqueConstraint(columnNames = "SUB_LOGIN") })
public class SubscriberEntity implements Serializable {

	private static final long serialVersionUID = 7501200190065409789L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "SUB_ID")
	private Integer id;

	@Column(name = "SUB_NAME", nullable = false)
	private String name;

	@Column(name = "SUB_FORNAME", nullable = false)
	private String forename;

	@Column(name = "SUB_LOGIN", nullable = false)
	private String login;

	@Column(name = "SUB_PWD", nullable = false)
	private String password;

	@OneToMany(mappedBy = "subscriber")
	private List<BookBorrowingEntity> booksBorrowed;

	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the forename
	 */
	public String getForename() {
		return forename;
	}

	/**
	 * @param forename
	 *            the forename to set
	 */
	public void setForename(String forename) {
		this.forename = forename;
	}

	/**
	 * @return the login
	 */
	public String getLogin() {
		return login;
	}

	/**
	 * @param login
	 *            the login to set
	 */
	public void setLogin(String login) {
		this.login = login;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the booksBorrowed
	 */
	public List<BookBorrowingEntity> getBooksBorrowed() {
		return booksBorrowed;
	}

	/**
	 * @param booksBorrowed
	 *            the booksBorrowed to set
	 */
	public void setBooksBorrowed(List<BookBorrowingEntity> booksBorrowed) {
		this.booksBorrowed = booksBorrowed;
	}
}
